package primary.linkedList;

/**
 * @Author Elephas
 * @Date 2022/1/8
 **/
public class ListNode {
    int val;
    ListNode next;
    ListNode() {}
    ListNode(int val) { this.val = val; }
    ListNode(int val, ListNode next) { this.val = val; this.next = next; }

    public static ListNode ListNode(int[] vals){
        if(vals.length == 0){
            return null;
        }
        ListNode head = new ListNode(vals[0],null);
        ListNode tail = head;
        for (int i = 1; i < vals.length; i++) {
            ListNode temp = new ListNode(vals[i],null);
            tail.next = temp;
            tail = temp;
        }
        tail.next = null;
        return head;
    }
}
